class RailRenderer : public IBlockRenderer
{
public:
	ITexture *Texture;
	Point2i TextureOffset;

	RailRenderer(ITexture *texture, const Point2i &offset) :
		Texture(texture),
		TextureOffset(offset)
	{
	}

	int GetTypeData(const int &data) { return data; }

	void Render(Schematic *schematic, RendererBase *renderer, const Block &block, const Point3i &position)
	{
		byte dir = block.Data & ~0x08;
		auto pos = TextureOffset;
		Point3f points[] =
		{
			Point3f(0, 15, 0),
			Point3f(16, 15, 0),
			Point3f(16, 15, 16),
			Point3f(0, 15, 16)
		};

		renderer->Translate(8, 8, 8);

		switch (block.Data)
		{
			case 1:
				renderer->Rotate(90, 0, 1, 0);
				break;
			case 2:
				renderer->Rotate(-90, 0, 1, 0);
				points[0].Y = points[1].Y = -1;
				break;
			case 3:
				renderer->Rotate(90, 0, 1, 0);
				points[0].Y = points[1].Y = -1;
				break;
			case 4:
				points[0].Y = points[1].Y = -1;
				break;
			case 5:
				renderer->Rotate(180, 0, 1, 0);
				points[0].Y = points[1].Y = -1;
				break;
			case 6:
				pos.Y -= 16;
				break;
			case 7:
				pos.Y -= 16;
				renderer->Rotate(-90, 0, 1, 0);
				break;
			case 8:
				pos.Y -= 16;
				renderer->Rotate(180, 0, 1, 0);
				break;
			case 9:
				pos.Y -= 16;
				renderer->Rotate(-270, 0, 1, 0);
				break;
		}

		if (block.ID == 27 &&
			(block.Data & 0x08) != 0)
			pos.Y += 16;

		renderer->Translate(-8, -8, -8);

		renderer->Draw(Face(points[0], points[1], points[2], points[3], Colorb::White, Texture, pos, 16, 16));
	}
};